﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsProfileDAL
/// </summary>
public class clsProfileDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsProfileDAL()
    {

        //
        // TODO: Add constructor logic here
        //
    }
    public List<IN_TB_PROFILE> GetAllProfile()
    {
        try
        {
            List<IN_TB_PROFILE> objIN_TB_PROFILE = new List<IN_TB_PROFILE>();
            objIN_TB_PROFILE = (from obj in objInstantNaukriDataContextDataContext.IN_TB_PROFILEs
                                select obj).ToList();
            return objIN_TB_PROFILE;
        }
        catch (Exception)
        {

            throw;
        }
    }
    public IN_TB_PROFILE GetProfileById(int ID)
    {
        try
        {
            IN_TB_PROFILE objIN_TB_PROFILE = new IN_TB_PROFILE();
            objIN_TB_PROFILE = (from obj in objInstantNaukriDataContextDataContext.IN_TB_PROFILEs
                                where obj.ID == ID
                                select obj).SingleOrDefault();
            return objIN_TB_PROFILE;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_PROFILE GetProfileByUserId(int UserId)
    {
        try
        {
            IN_TB_PROFILE objIN_TB_PROFILE = new IN_TB_PROFILE();
            objIN_TB_PROFILE = (from obj in objInstantNaukriDataContextDataContext.IN_TB_PROFILEs
                                where obj.USER_ID == UserId
                                select obj).SingleOrDefault();
            return objIN_TB_PROFILE;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveProfile(IN_TB_PROFILE objIN_TB_PROFILE)
    {
        try
        {
            IN_TB_PROFILE objIN_TB_PROFILEID = new IN_TB_PROFILE();
            objIN_TB_PROFILEID = (from obj in objInstantNaukriDataContextDataContext.IN_TB_PROFILEs
                                  where obj.ID == objIN_TB_PROFILE.ID
                                  select obj).SingleOrDefault();
            if (objIN_TB_PROFILEID != null)
            {
                objIN_TB_PROFILEID.ID = objIN_TB_PROFILE.ID;
                objIN_TB_PROFILEID.USER_ID = objIN_TB_PROFILE.USER_ID;
                objIN_TB_PROFILEID.F_NAME = objIN_TB_PROFILE.F_NAME;
                objIN_TB_PROFILEID.M_NAME = objIN_TB_PROFILE.M_NAME;
                objIN_TB_PROFILEID.L_NAME = objIN_TB_PROFILE.L_NAME;
                objIN_TB_PROFILEID.FATHER = objIN_TB_PROFILE.FATHER;
                objIN_TB_PROFILEID.DOB = objIN_TB_PROFILE.DOB;
                objIN_TB_PROFILEID.GENDER = objIN_TB_PROFILE.GENDER;
                objIN_TB_PROFILEID.CITY = objIN_TB_PROFILE.CITY;
                objIN_TB_PROFILEID.PHONE = objIN_TB_PROFILE.PHONE;
                objIN_TB_PROFILEID.MOBILE = objIN_TB_PROFILE.MOBILE;
                objIN_TB_PROFILEID.EMAIL = objIN_TB_PROFILE.EMAIL;
                objIN_TB_PROFILEID.MARITAL_STATUS = objIN_TB_PROFILE.MARITAL_STATUS;
                objIN_TB_PROFILEID.MODIFIED_ON = DateTime.Now;
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_PROFILEID.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_PROFILEs.InsertOnSubmit(objIN_TB_PROFILE);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_PROFILE.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveProfile(int UserId)
    {
        throw new NotImplementedException();
    }
}
